//
//  YCTeachDetailCell.m
//  YCSchool
//
//  Created by gmall on 16/5/24.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  教学详情中,学生卡片视图

#import "YCTeachDetailCell.h"

@implementation YCTeachDetailCell
@synthesize nameLabel = _nameLabel;
@synthesize iconImage = _iconImage;
@synthesize upDownButton = _upDownButton;

- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        
        UIView *bg = [[UIView alloc] init];
        bg.backgroundColor = [UIColor whiteColor];
        bg.layer.cornerRadius = 6;
        bg.clipsToBounds = YES;
        [self.contentView addSubview:bg];
        
        _iconImage = [[UIImageView alloc]init];
        _iconImage.clipsToBounds = NO;
        _iconImage.contentMode = UIViewContentModeScaleAspectFill;
        _iconImage.layer.cornerRadius = 70 / 2.0;
        _iconImage.layer.masksToBounds = YES;
        _iconImage.userInteractionEnabled = YES;
        [bg addSubview:_iconImage];
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont systemFontOfSize:15];
        _nameLabel.textColor = [UIColor blackColor];
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        [bg addSubview:self.nameLabel];
        
        _upDownButton = [[UIButton alloc] init];
        _upDownButton.backgroundColor = [UIColor orangeColor];
        [_upDownButton setTitle:@"下车" forState:UIControlStateNormal];
        [_upDownButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _upDownButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_upDownButton addTarget:self action:@selector(upDownButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        _upDownButton.layer.cornerRadius = 3;
        _upDownButton.layer.masksToBounds = YES;
        [bg addSubview:_upDownButton];
        
        
        [bg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.and.left.right.equalTo(self.contentView);
        }];
        
        [_iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(bg);
            make.bottom.equalTo(bg.mas_centerY).offset(0);
            make.height.width.equalTo(@70);
        }];
        
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bg.mas_centerY).offset(8);
            make.left.right.equalTo(bg);
        }];
        
        [_upDownButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(10);
            make.centerX.equalTo(bg);
            make.width.equalTo(@70);
        }];
        
    }
    return self;
}

- (void)upDownButtonClick:(UIButton *)button
{
    if ([_delegate respondsToSelector:@selector(teachDetailCell:didClickUpdownBtn:)]) {
        [_delegate teachDetailCell:self didClickUpdownBtn:button];
    }
}


@end
